package cn.cdiothree.controller;

import cn.cdiothree.dataobject.OrderComment;
import cn.cdiothree.service.OrderCommentService;
import cn.cdiothree.vo.ResultVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 订单图文评论
 * @author cumthing
 */
@RestController
@RequestMapping("/order-comment")
public class OrderCommentController {
    @Autowired
    OrderCommentService orderCommentService;

    /**
     * 添加商品评论
     * @param userId
     * @param orderId
     * @param commentText
     * @return
     */
    @PostMapping("/add")
    public ResultVo addTextComment(@RequestParam("userId") Integer userId,
                                   @RequestParam("orderId") String orderId, String commentText){
        ResultVo orderComment = orderCommentService.addTextComment(userId,orderId,commentText);
        return ResultVo.success(orderComment);
    }

    /**
     * 获取商品评论
     * @param userId
     * @param orderId
     * @return
     */
    @GetMapping("/get")
    public ResultVo getCommentList(@RequestParam("userId") Integer userId,
                                   @RequestParam("orderId") String orderId){
        List<OrderComment> orderComment = orderCommentService.getCommentList(userId,orderId);
        return ResultVo.success(orderComment);
    }
}
